package org.sport.repository;

import org.sport.model.entityModel.ActivitytableEntity;
import org.sport.model.entityModel.UsertableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;


@Repository
public interface ActivitytableRepository extends JpaRepository<ActivitytableEntity,Integer> {

    @Transactional
    @Query("select act from ActivitytableEntity act where act.usertableByOwnerId =?1")
    public List<ActivitytableEntity> findActByUserId(UsertableEntity usertableEntity);

    @Modifying
    @Transactional
    @Query("update ActivitytableEntity act set " +
            "act.theam=:qTheam, " +
            "act.location=:qLocation, " +
            "act.inviteeId=:qInviteeId, " +
            "act.status=:qStatus, " +
            "act.brief=:qBrief" +
            " where act.id=:qid")
    public void updateContentByActId(@Param("qTheam") String theam,
                                        @Param("qLocation") String location,
                                        @Param("qInviteeId") String inviteeId,
                                        @Param("qStatus") String Status,
                                        @Param("qBrief") String brief,
                                        @Param("qid")  Integer id
    );

    @Modifying
    @Transactional
    @Query("update ActivitytableEntity act set " +
            "act.status=:qStatus" +
            " where act.id=:qid")
    public void updateStatusByActId(@Param("qStatus") String status,
                                     @Param("qid")  Integer id
    );
}
